package com.example.locationtracking.model;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import com.example.locationtracking.utils.Const;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonRootName(value="Location")
public class UserLocation implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@JsonProperty("ID")
	private int id;
	@JsonProperty("UserName")
	private String username;
	@JsonProperty("Latitude")
	private String latitude;
	@JsonProperty("Longitude")
	private String longitude;
	@JsonProperty("Time")
	private String Time;
	public UserLocation() {
		super();
	}
	public UserLocation(int id, String username, String latitude, String longitude,
			String time) {
		super();
		this.id = id;
		this.username = username;
		this.latitude = latitude;
		this.longitude = longitude;
		this.Time = time;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getLatitude() {
		return latitude;
	}
	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}
	public String getLongitude() {
		return longitude;
	}
	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
	public String getTime() {
		return Time;
	}
	public void setTime(String time) {
		Time = time;
	}
	public Date getDateTime(){
		DateFormat format = new SimpleDateFormat(Const.DATE_FORMAT);
		try {
			return format.parse(Time);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return Calendar.getInstance().getTime();
	}
}
